Skip to contentSkip to conversation

Change in openvpn[master]: CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages May 7, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1746615872000.I2551edfaaf5107649398a3fa1db2009ee8644671@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/981?usp=email

to review the following change.

Change subject: CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path
......................................................................

CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path

This makes sure that it is properly normalized, and on Windows seems to prevent CMake from using back slashes which would break the build due to "unknown escape sequence" errors.

Change-Id I2551edfaaf5107649398a3fa1db2009ee8644671

---
M CMakeLists.txt

1 file changed, 2 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/981/1

CMakeLists.txt +2 -2
index a8fb64b..6687b56 100644
@@ -679,11 +679,11 @@
     endif ()
 
     foreach (test_name ${unit_tests})
+        cmake_path(SET _UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
         # test_networking needs special environment
         if (NOT ${test_name} STREQUAL "test_networking")
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
-            set(_UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
             set_tests_properties(${test_name} PROPERTIES
                 ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
         endif ()
@@ -703,7 +703,7 @@
 
         # for compat with IDEs like Clion that ignore the tests properties
         # for the environment variable srcdir when running tests as fallback
-        target_compile_definitions(${test_name} PRIVATE "-DUNIT_TEST_SOURCEDIR=\"${CMAKE_SOURCE_DIR}/tests/unit_tests/openvpn\"")
+        target_compile_definitions(${test_name} PRIVATE "UNIT_TEST_SOURCEDIR=\"${_UT_SOURCE_DIR}\"")
 
         if (NOT ${test_name} STREQUAL "test_buffer")
             target_sources(${test_name} PRIVATE

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/981?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2551edfaaf5107649398a3fa1db2009ee8644671
Gerrit-Change-Number: 981
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/981?usp=email )

Change subject: CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/981?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2551edfaaf5107649398a3fa1db2009ee8644671
Gerrit-Change-Number: 981
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 07 May 2025 11:57:03 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

This makes sure that it is properly normalized, and on Windows seems to prevent CMake from using back slashes which would break the build due to "unknown escape sequence" errors.

Change-Id I2551edfaaf5107649398a3fa1db2009ee8644671

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/981
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>

CMakeLists.txt +2 -2
index a8fb64b..6687b56 100644
@@ -679,11 +679,11 @@
     endif ()
 
     foreach (test_name ${unit_tests})
+        cmake_path(SET _UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
         # test_networking needs special environment
         if (NOT ${test_name} STREQUAL "test_networking")
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
-            set(_UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
             set_tests_properties(${test_name} PROPERTIES
                 ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
         endif ()
@@ -703,7 +703,7 @@
 
         # for compat with IDEs like Clion that ignore the tests properties
         # for the environment variable srcdir when running tests as fallback
-        target_compile_definitions(${test_name} PRIVATE "-DUNIT_TEST_SOURCEDIR=\"${CMAKE_SOURCE_DIR}/tests/unit_tests/openvpn\"")
+        target_compile_definitions(${test_name} PRIVATE "UNIT_TEST_SOURCEDIR=\"${_UT_SOURCE_DIR}\"")
 
         if (NOT ${test_name} STREQUAL "test_buffer")
             target_sources(${test_name} PRIVATE
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path

I have no idea what this is about :-) - but it's fixing build fails for "we want to do automated tests on windows VMs via GHA", so this is important. No code change, only cmake build environment.

Your patch has been applied to the master branch.

commit b6af9b2841005cf139bf8d0c3ed40561903b59af

Author: Frank Lichtenheld
Date:   Wed May 7 14:12:20 2025 +0200
     CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg31587.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/981?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by plaisthos

Change subject: CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path
......................................................................

CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path

This makes sure that it is properly normalized, and on Windows seems to prevent CMake from using back slashes which would break the build due to "unknown escape sequence" errors.

Change-Id I2551edfaaf5107649398a3fa1db2009ee8644671

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31587.html

---
M CMakeLists.txt

1 file changed, 2 insertions(+), 2 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/81/981/2

CMakeLists.txt +2 -2
index a8fb64b..6687b56 100644
@@ -679,11 +679,11 @@
     endif ()
 
     foreach (test_name ${unit_tests})
+        cmake_path(SET _UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
         # test_networking needs special environment
         if (NOT ${test_name} STREQUAL "test_networking")
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
-            set(_UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
             set_tests_properties(${test_name} PROPERTIES
                 ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
         endif ()
@@ -703,7 +703,7 @@
 
         # for compat with IDEs like Clion that ignore the tests properties
         # for the environment variable srcdir when running tests as fallback
-        target_compile_definitions(${test_name} PRIVATE "-DUNIT_TEST_SOURCEDIR=\"${CMAKE_SOURCE_DIR}/tests/unit_tests/openvpn\"")
+        target_compile_definitions(${test_name} PRIVATE "UNIT_TEST_SOURCEDIR=\"${_UT_SOURCE_DIR}\"")
 
         if (NOT ${test_name} STREQUAL "test_buffer")
             target_sources(${test_name} PRIVATE

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/981?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2551edfaaf5107649398a3fa1db2009ee8644671
Gerrit-Change-Number: 981
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/981?usp=email )

Change subject: CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path
......................................................................

CMake: Make sure to treat UNIT_TEST_SOURCEDIR as path

This makes sure that it is properly normalized, and on Windows seems to prevent CMake from using back slashes which would break the build due to "unknown escape sequence" errors.

Change-Id I2551edfaaf5107649398a3fa1db2009ee8644671

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg31587.html

---
M CMakeLists.txt

1 file changed, 2 insertions(+), 2 deletions(-)
CMakeLists.txt +2 -2
index a8fb64b..6687b56 100644
@@ -679,11 +679,11 @@
     endif ()
 
     foreach (test_name ${unit_tests})
+        cmake_path(SET _UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
         # test_networking needs special environment
         if (NOT ${test_name} STREQUAL "test_networking")
             add_test(${test_name} ${test_name})
             # for compat with autotools make check
-            set(_UT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_tests/openvpn)
             set_tests_properties(${test_name} PROPERTIES
                 ENVIRONMENT "srcdir=${_UT_SOURCE_DIR}")
         endif ()
@@ -703,7 +703,7 @@
 
         # for compat with IDEs like Clion that ignore the tests properties
         # for the environment variable srcdir when running tests as fallback
-        target_compile_definitions(${test_name} PRIVATE "-DUNIT_TEST_SOURCEDIR=\"${CMAKE_SOURCE_DIR}/tests/unit_tests/openvpn\"")
+        target_compile_definitions(${test_name} PRIVATE "UNIT_TEST_SOURCEDIR=\"${_UT_SOURCE_DIR}\"")
 
         if (NOT ${test_name} STREQUAL "test_buffer")
             target_sources(${test_name} PRIVATE

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/981?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2551edfaaf5107649398a3fa1db2009ee8644671
Gerrit-Change-Number: 981
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged